﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace LF.Application.Helpers
{
    public static class ValidateHelper
    {
        
        public static bool IsValidPhoneNumber(this string phoneNumber)
        {
            Regex ChinaMainlandRegex = new Regex(@"^1[3-9]\d{9}$", RegexOptions.Compiled);
         Regex HongKongRegex = new Regex(@"^([569])\d{7}$", RegexOptions.Compiled);
         Regex MacauRegex = new Regex(@"^6\d{7}$", RegexOptions.Compiled);
            if (string.IsNullOrWhiteSpace(phoneNumber))
            {
                return false;
            }

            // 校验是否符合中国大陆、香港、澳门手机号格式
            return ChinaMainlandRegex.IsMatch(phoneNumber) ||
                   HongKongRegex.IsMatch(phoneNumber) ||
                   MacauRegex.IsMatch(phoneNumber);
        }
    }
}
